/* @author: 	 Jeramie Hallyburton
 * @file:		 SpaceInvadersActivity.java
 * @date:		 12/09/2011
 * @description: Activity for main menu
 */
package mobiledev.project3.spaceinvaders;

import game.spaceinvaders.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;

public class SpaceInvadersActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
	private static final String TAG = SpaceInvadersActivity.class.getSimpleName();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        setContentView( R.layout.main );
        //setContentView( new SpaceInvadersView(this) );
        
        // Set up click listeners for all the buttons
        View continueButton = findViewById(R.id.continue_button);
        continueButton.setOnClickListener(this);
        View newButton = findViewById(R.id.new_button);
        newButton.setOnClickListener(this);
        View aboutButton = findViewById(R.id.about_button);
        aboutButton.setOnClickListener(this);
        View exitButton = findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
        
    }
    
    private void startGame( int i ) {
        Intent intent = new Intent(this, Game.class);
        intent.putExtra( "STATUS", i );
        startActivity(intent);
     }

    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.new_button:
           startGame( 0 );
           break;
        case R.id.continue_button:
        	startGame( 1 );
            break;
        case R.id.about_button:
        	final AlertDialog.Builder aboutBox = new AlertDialog.Builder(this);
        	aboutBox.setTitle( "Space Invaders: About" );
        	aboutBox.setMessage( getString( R.string.about ) );
        	aboutBox.show();
           break;
        case R.id.exit_button:
        	finish();
            break;
        }
     }
    
    @Override
    protected void onResume() {
       super.onResume();
       Music.play(this, R.raw.space);
    }
 	
 	@Override
 	protected void onPause() {
       super.onPause();
       Log.d(TAG, "onPause");
       Music.stop(this);
 	}
}